package com.wilmer.aiUserMsg.service.impl;

import java.util.List;
import com.wilmer.common.utils.DateUtils;
import com.wilmer.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wilmer.aiUserMsg.mapper.YwUserMsgMapper;
import com.wilmer.aiUserMsg.domain.YwUserMsg;
import com.wilmer.aiUserMsg.service.IYwUserMsgService;

/**
 * 对话信息Service业务层处理
 *
 * @author hans
 * @date 2024-05-15
 */
@Service
public class YwUserMsgServiceImpl implements IYwUserMsgService
{
    @Autowired
    private YwUserMsgMapper ywUserMsgMapper;

    /**
     * 查询对话信息
     *
     * @param msgId 对话信息主键
     * @return 对话信息
     */
    @Override
    public YwUserMsg selectYwUserMsgByMsgId(Long msgId)
    {

        return ywUserMsgMapper.selectYwUserMsgByMsgId(msgId);
    }

    /**
     * 查询对话信息列表
     *
     * @param ywUserMsg 对话信息
     * @return 对话信息
     */
    @Override
    public List<YwUserMsg> selectYwUserMsgList(YwUserMsg ywUserMsg)
    {
        return ywUserMsgMapper.selectYwUserMsgList(ywUserMsg);
    }

    /**
     * 新增对话信息
     *
     * @param ywUserMsg 对话信息
     * @return 结果
     */
    @Override
    public int insertYwUserMsg(YwUserMsg ywUserMsg)
    {
        ywUserMsg.setUserId(SecurityUtils.getUserId());
        ywUserMsg.setDeptId(SecurityUtils.getDeptId());
        ywUserMsg.setCreateTime(DateUtils.getNowDate());
        return ywUserMsgMapper.insertYwUserMsg(ywUserMsg);
    }

    /**
     * 修改对话信息
     *
     * @param ywUserMsg 对话信息
     * @return 结果
     */
    @Override
    public int updateYwUserMsg(YwUserMsg ywUserMsg)
    {
        ywUserMsg.setUpdateTime(DateUtils.getNowDate());
        return ywUserMsgMapper.updateYwUserMsg(ywUserMsg);
    }

    /**
     * 批量删除对话信息
     *
     * @param msgIds 需要删除的对话信息主键
     * @return 结果
     */
    @Override
    public int deleteYwUserMsgByMsgIds(Long[] msgIds)
    {
        return ywUserMsgMapper.deleteYwUserMsgByMsgIds(msgIds);
    }

    /**
     * 删除对话信息信息
     *
     * @param msgId 对话信息主键
     * @return 结果
     */
    @Override
    public int deleteYwUserMsgByMsgId(Long msgId)
    {
        return ywUserMsgMapper.deleteYwUserMsgByMsgId(msgId);
    }

    @Override
    public void test() {
        System.out.println("---------------");
//        System.out.println(SecurityUtils.getLoginUser());
    }
}
